//
//  EarningViewController.m
//  lcf-newproject
//
//  Created by yangyang on 14-11-24.
//  Copyright (c) 2014年 yang. All rights reserved.
//

#import "EarningViewController.h"
#import "CKCalendarView.h"
#import "EarningViewCell.h"
#import "SettingManager.h"
@interface EarningViewController ()

@property (nonatomic,strong)UITableView * tableView;
@property (nonatomic,strong)NSMutableArray * dataArray;
@property (nonatomic,strong)CKCalendarView * calendarView;

@end

@implementation EarningViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self uiConfig];
    // Do any additional setup after loading the view.
}

-(void)uiConfig{
    _dataArray = [[NSMutableArray alloc]init];
    _tableView = [self creataTableViewWithFrame:CGRectMake(0, 0, __MainScreen_Width, __MainScreen_Height-__TabBar_Height) withTableViewStyle:UITableViewStylePlain];
    _tableView.backgroundColor = [SettingManager hexStringToColor:@"f3f3f3"];
    _tableView.showsVerticalScrollIndicator = NO;
    [_tableView setSeparatorInset:UIEdgeInsetsZero];
    [self.view addSubview:_tableView];
    
    
    
}

#pragma  mark -  创建日历View
-(CKCalendarView *)createCalendarView{
    _calendarView = [[CKCalendarView alloc]initWithStartDay:startMonday];
    _calendarView.frame = CGRectMake(0, 0, __MainScreen_Width, 285);
    return _calendarView;
}


#pragma mark - UITableViewDeleagte
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return Calendarheight;
    }
    return EarningCellHeight;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if(section == 0)     return 10;
    else return 0;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

}

#pragma mark - UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section == 0){
        return 1;
    }
    else{
        return 3;
    }
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        static NSString * cellIde = @"earningCell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIde];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIde];
            _calendarView = [self createCalendarView];
        }
        [cell.contentView addSubview:_calendarView];
        return cell;
    }else{
        static NSString * cellIde = @"EarningViewCell";
        EarningViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIde];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle]loadNibNamed:@"EarningViewCell" owner:self options:nil]lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.earningMountLabel.text = @"338元";
        cell.earningTimeLabel.text = @"2015-10-10 10：25：39";
        cell.earningTitleLable.text = @"客运公司运营车辆更新借款项目（二期）";
        cell.earningTypeLabel.text = @"利息";
        if(indexPath.row == 0){
            cell.earningTypeImageView.image = [UIImage imageNamed:@"li.png"];
        }else if(indexPath.row == 1){
            cell.earningTypeImageView.image = [UIImage imageNamed:@"huan.png"];
        }else{
            cell.earningTypeImageView.image = [UIImage imageNamed:@"ben.png"];
        }
        
        return cell;
    }
    return nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
